<?php

class Application_Model_WayLog extends Application_Model_DomainObject{
    
    protected $_id;
    
    protected $_description;
    
    protected $_dateCreated;
    
    protected $_isShowFront;
    
    protected $_wayId;
    
    protected $_operator;

    protected $_operateType;
    
    protected $_type;

    /**
     * 预估长宽高
     */
    const Type_BillVolume = 201;
    /**
     * 修改后的渠道公司
     */
    const Type_BillAffirmAgent = 202;
    /**
     * 修改后的渠道方式
     */
    const Type_BillAffirmChannel = 203;
    /**
     * 是否查看物流信息
     */
    const OperateType_Seen = 204;
    /**
     * 商易的包裹属性
     */
    const Type_PropertySY = 205;
    /**
     * 运送方式
     */
    const Type_ShipType = 206;

    const Type_Bill = 1;
    
    const Type_Visiting = 2;
    
    const Type_Return = 3;
    /**
     * 根据运单ID返回运单的操作日志
     * @param type $wayId
     */
    public static function getByWayId($wayId){
        return self::getDao()->queryAll(array('wayId = '=>$wayId));
    }
    
    public static function getByWayIdInteriorType($wayId,$interior,$type = Application_Model_WayLog::Type_Bill)
    {
        return self::getDao()->queryOne(array("wayId = "=>$wayId," and operateType = "=>$interior," and type = "=>$type));
    }
    
    public function getDescriptionByAgent()
    {
        return Application_Model_AgentCompany::load($this->_description);
    }
    
    public function getDescriptionByChannel()
    {
        return Application_Model_ExpressChannel::load($this->_description);
    }
    
    public function getDescriptionByExpressId()
    {
        return Application_Model_Expressbychannel::getChannelIdByExpress($this->_description);
    }
    
    public static function getTypeByWayBill($type)
    {
        return self::getDao()->queryAll(array("operateType"=>$type));
    }
    
    public static function getAgentIdTypeByWayBill($agentid,$type)
    {
        return self::getDao()->queryAll(array("description = "=>$agentid," and operateType = "=>$type));
    }
    
    public static function getCountByTypeOperator($operateType,$nikeName,$type,$startDate,$endDate)
    {
        $wayLogDb = new Application_Model_DbTable_WayLog();
        return $wayLogDb->getCountByTypeOperator($operateType,$nikeName,$type,$startDate,$endDate);
    }
    
    public static function getPackSize($id,$type,$operateType){
        return self::getDao()->queryOne(array('wayId'=>$id,'type'=>$type,'operateType'=>$operateType));
    }
}